<template>
  <div class="rights">
    <!-- 面包屑 -->
    <el-breadcrumb
      separator="/"
      style="line-height:45px;"
    >
      <el-breadcrumb-item :to="{ path: '/home' }">首页</el-breadcrumb-item>
      <el-breadcrumb-item>权限管理</el-breadcrumb-item>
      <el-breadcrumb-item>权限列表</el-breadcrumb-item>
    </el-breadcrumb>
    <!-- 权限列表 -->
    <template>
      <el-table
        ref="singleTable"
        :data="rightList"
        style="width: 100%;margin-top:15px;"
        border
      >
        <el-table-column
          type="index"
          width="50"
        >
        </el-table-column>
        <el-table-column
          property="authName"
          label="权限"
          width="200"
        >
        </el-table-column>
        <el-table-column
          property="path"
          label="路径"
          width="200"
        >
        </el-table-column>
        <el-table-column
          label="层级"
        >
        <template slot-scope="scope">
          <span>{{scope.row.level|levelFormat}}</span>
        </template>
        </el-table-column>
      </el-table>
    </template>
</div>
</template>
<script>
import {getRightList} from '@/api'
export default {
  data () {
    return {
      rightList: []
    }
  },
  mounted () {
    getRightList('list')
      .then(res => {
        console.log(res)
        if (res.meta.status === 200) {
          this.rightList = res.data
        }
      })
  },
  // 局部区域过滤器
  filters: {
    levelFormat (level) {
      if (level === '0') {
        return '一级'
      } else if (level === '1') {
        return '二级'
      } else if (level === '2') {
        return '三级'
      }
    }
  }
}
</script>
<style lang="scss" scoped>
</style>
